import Mock from "mockjs";

const dataList = [];
for (let i = 0; i < 30; i++) {
  dataList.push({
    Cname: "学员" + i,
    Ename: "hekangi",
    age: i,
    grade: "初一",
    chinese: "80",
    tap: "不及格",
    mathematics: "20",
    english: "40",
  });
}
Mock.mock("/getInfo", "post", (params) => {
  var info = JSON.parse(params.body);
  var [index, size, total] = [info.pageIndex, info.pageSize, dataList.length];
  var len = total / size;
  var totalPages = len - parseInt(len) > 0 ? parseInt(len) + 1 : len;
  var newDataList = dataList.slice((index - 1) * size, index * size);
  return {
    code: "0",
    message: "success",
    data: {
      pageIndex: index,
      pageSize: size,
      list: newDataList,
      total: total,
      totalPages: totalPages,
    },
  };
});
